package com.wang.spring.aop;

import com.alibaba.fastjson.JSONObject;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class GlobalAop {
//    @Pointcut("execution(* com.wang.spring.controller.MainController.get(..))")
    public void controller() {
    }

//    @Around("controller()")
    public Object doAfterReturning(ProceedingJoinPoint pjp) throws Throwable {
        Object r = pjp.proceed();
        JSONObject json = new JSONObject();
        json.put("code", 0);
        json.put("data", r);
        System.out.println("123");
        return json;
    }
}
